import { ElMessage, ElMessageBox } from 'element-plus';

const ADD_SUCCESS_NOTICE = '添加成功';
const UPDATE_SUCCESS_NOTICE = '修改成功';
const DELETE_SUCCESS_NOTICE = '删除成功';
const SAVE_SUCCESS_NOTICE = '保存成功';
const SAVE_ERROR_NOTICE = '保存失败';

const ADD_ERROR_NOTICE = '添加失败';
const UPDATE_ERROR_NOTICE = '修改失败';
const DELETE_ERROR_NOTICE = '删除失败';

const DOWN_SUCCESS_NOTICE = '下架成功';
const DOWN_ERROR_NOTICE = '下架失败';

const UP_SUCCESS_NOTICE = '上架成功';
const UP_ERROR_NOTICE = '上架失败';

const ENABLE_SUCCESS_NOTICE = '启用成功';
const ENABLE_ERROR_NOTICE = '启用失败';

const DISABLE_SUCCESS_NOTICE = '停用成功';
const DISABLE_ERROR_NOTICE = '停用失败';
/**
 * 成功通知
 * @param type
 */
export const MessageSuccess = (type: string) => {
	switch (type) {
		case 'add':
			ElMessage.success({ message: ADD_SUCCESS_NOTICE });
			break;
		case 'upd':
			ElMessage.success({ message: UPDATE_SUCCESS_NOTICE });
			break;
		case 'del':
			ElMessage.success({ message: DELETE_SUCCESS_NOTICE });
			break;
		case 'save':
			ElMessage.success({ message: SAVE_SUCCESS_NOTICE });
			break;
		case 'down':
			ElMessage.success({ message: DOWN_SUCCESS_NOTICE });
			break;
		case 'up':
			ElMessage.success({ message: UP_SUCCESS_NOTICE });
			break;
		case 'enable':
			ElMessage.success({ message: ENABLE_SUCCESS_NOTICE });
			break;
		case 'disable':
			ElMessage.success({ message: DISABLE_SUCCESS_NOTICE });
			break;
	}
};

/**
 * 失败通知
 * @param type
 */
export const MessageError = (type: string) => {
	switch (type) {
		case 'add':
			ElMessage.error({ message: ADD_ERROR_NOTICE });
			break;
		case 'upd':
			ElMessage.error({ message: UPDATE_ERROR_NOTICE });
			break;
		case 'del':
			ElMessage.error({ message: DELETE_ERROR_NOTICE });
			break;
		case 'save':
			ElMessage.error({ message: SAVE_ERROR_NOTICE });
			break;
		case 'down':
			ElMessage.success({ message: DOWN_ERROR_NOTICE });
			break;
		case 'up':
			ElMessage.success({ message: UP_ERROR_NOTICE });
			break;
		case 'enable':
			ElMessage.success({ message: ENABLE_ERROR_NOTICE });
			break;
		case 'disable':
			ElMessage.success({ message: DISABLE_ERROR_NOTICE });
			break;
	}
};

/**
 *  自定义通知
 * @param type
 * @param message
 * @constructor
 */
export const MessageCustom = (type: string = 'info', message: any) => {
	switch (type) {
		case 'success':
			ElMessage.success({ message: message });
			break;
		case 'warning':
			ElMessage.warning({ message: message });
			break;
		case 'info':
			ElMessage.info({ message: message });
			break;
		case 'error':
			ElMessage.error({ message: message });
			break;
	}
};

export const ConfirmCustom = (options: any = { type: 'info' }, message = '您确认删除所选内容吗？', title = '提示') => {
	return ElMessageBox.confirm(message, title, options);
};
